/*
* Copyright 2010 Pavel Kozhin 
*
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License. 
* You may obtain a copy of the License at 
* 
* http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed  under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License.
*
* Author: Pavel Kozhin.
*/

package org.bookmarksframework
{
	import org.bookmarksframework.browser.IBrowserAdapter;
	import org.bookmarksframework.history.IHistory;

	public class BookmarksConfig
	{
		/**
		 *  Path separator is used to separate fragment parts from each other
		 *  e.g. fragmentPart1/fragmentPart2/fragmentPart3.
		 * 
		 *  @default "/"
		 */
		public var pathSeparator:String = "/";
		
		/**
		 *  Committing path calls traversing fragments which belong to committed 
		 *  path, so this value is used to vary frames needed for delay between 
		 *  fragments committments during traversing. 
		 *  <p>It affects performance and the whole time of path processing.</p>
		 * 
		 *  @default 1
		 */
		public var committmentDelay:int = 1;
		
		/**
		 *  It forces paths to be strict which means always to start with path 
		 *  separator. 
		 * 
		 *  @default false 
		 */
		public var useStrictPath:Boolean = false;
		
		[Bindable]
		
		/**
		 *  It represents adapter for any custom object which can provide necessary 
		 *  functionality to support browser management. Bookmarks framework provides 
		 *  two default classes as adapters <code>BrowserManagerAdapter</code> and 
		 *  <code>SWFAddressAdapter</code>.
		 *  <p>
		 *  <code>IBrowserAdapter</code> can be used as history management interface
		 *  because it extends <code>IBrowserHistory</code> which supports standard
		 *  web browser history API (see http://www.w3schools.com/jsref/obj_history.asp).
		 *  </p>
		 * 
		 *  @see org.bookmarksframework.core.browser.BrowserManagerAdapter
		 *  @see org.bookmarksframework.core.browser.SWFAddressAdapter
		 * 
		 *  @default null 
		 */
		public var browserAdapter:IBrowserAdapter = null;
		
		[Bindable]
		
		/**
		 *  You can use <code>IHistory</code> interface to walk only through local 
		 *  history. Bookmarks framework provides <code>History</code> class as default 
		 *  local history manager.
		 *  <p>
		 *  If you decided to use <code>IBrowserAdapter</code> then you don't need to
		 *  configure <code>IHistory</code> because <code>IBrowserAdapter</code> 
		 *  extends <code>IBrowserHistory</code> interface and you can also use it as 
		 *  history management interface. Defining <code>IHistory</code> along with <code>
		 *  IBrowserAdapter</code> will not take effect because only <code>IBrowserAdapter
		 *  </code> interface will be used by framework as primary interface for history 
		 *  management.</p>
		 *  <p>
		 *  <code>IHistory</code> interface is more comprehensive in comparison with
		 *  <code>IBrowserHistory</code> and has getters for <code>next</code>, <code>
		 *  current</code>, <code>previous</code> and getter for all history collection.
		 *  On the contrary <code>IBrowserHistory</code> defines only <code>back()</code>, 
		 *  <code>forward()</code>, <code>go()</code> methods and <code>length</code> 
		 *  getter. It's because of web browser DOM history object API restrictions 
		 *  (see http://www.w3schools.com/jsref/obj_history.asp).
		 *  
		 *  @see org.bookmarksframework.core.history.History;
		 * 
		 *  @default null
		 */
		public var localHistory:IHistory = null;
		
		/**
		 *  Function is used to extract path from context. Context can be equal to path 
		 *  but its purpose to transfer additional information/data along with path.
		 *  For example there is a need to transfer additional data in the form of 
		 *  pairs name and value e.g. data1=true&data2=17 etc with a string which goes
		 *  after # sign in web browser, which means with bookmarks path. So you can get 
		 *  to string like "data1=true&[fragment1/fragment2/]data2=17&data1=foo" and 
		 *  <code>pathResolver</code> handles "fragment1/fragment2/" path extraction 
		 *  from the whole string/context.
		 *  
		 * <pre>function(context:String):String</pre>
		 * 
		 *  @default null
		 */
		public var pathResolver:Function = null;
		
		/**
		 *  Function is used to inject path into context.<br><br>
		 * 
		 *  <pre>function(path:String, context:String):String</pre>
		 * 
		 *  @default null
		 */
		public var contextFormatter:Function = null;
		
		/**
		 *  If this property is set to <code>true</code> then active path 
		 *  (see org.bookmarksframework.manager.IBookmarksManager().activePath) will be 
		 *  set up on application startup and appear in web browser url (if browserAdapter 
		 *  is configured).
		 *  <p>
		 *  On the contrary if it is set to <code>false</code> then active path will 
		 *  remain empty (and web browser url will also remain unchanged) until the first 
		 *  navigating action.
		 *  </p>
		 * 
		 *  @default false
		 */
		public var forceInitialActivePath:Boolean = false;
		
	}
}